function sockPairs(pairs, cycles) {
  const circle2=  Math.floor(cycles / 2);
  const circle3 = Math.floor(cycles / 3);
  const circle5 = Math.floor(cycles / 5);
  const circle10 =Math.floor(cycles / 10);
  const sum = (pairs*2 - circle2 + circle3 -circle5 + circle10*2)/2;
  if (sum < 0) return 0;
  else return Math.floor(sum);
}


console.log(sockPairs(1, 8));